﻿using System;
using System.Collections.Generic;

namespace PotatoSoft
{
    namespace VOCTS
    {
        namespace Workbench
        {
            public class Workspace
            {
                public Int32 WorkspaceID { get; set; }
                public string WorkspaceName { get; set; }
                public ICollection<Project> WorkspaceProjects { get; set; }

                public void AddProject(Project pr)
                {
                    //instantiate if necessary
                    if (WorkspaceProjects == null)
                    {
                        WorkspaceProjects = new List<Project>();
                    }

                    //add the project if it is not already in the list
                    if (!WorkspaceProjects.Contains(pr))
                    {
                        WorkspaceProjects.Add(pr);
                    }

                    //set the workspace property, but protect from circular reference
                    if (pr.Workspace != this)
                    {
                        pr.Workspace = this;
                    }
                }  
            }
        }
    }
}
